C---------------------------------------------------------
C    TOOLPACK/1    Release: 2.5
C---------------------------------------------------------
        PROGRAM ISTPL
 
        INTEGER POLPTH(81),TKNPTH(81),CMTPTH(81),I,
     +          OPTPTH(81),IODOPT,NOOPTS(2),IODTKN,IODCMT,IODPOL,
     +          NERROR,OPT(134)
        LOGICAL NOTDON
 
        INTEGER TMPFIL
 
        INTEGER GETARG,OPEN,CREATE,EQUAL,ZTKGTI,ZPLERR
        EXTERNAL ZINIT,GETARG,OPEN,CREATE,ERROR,EQUAL,ZTKGTI,ZPLERR
 
        SAVE
 
        DATA NOOPTS/45,129/
 
C Initialise TIE
 
        CALL ZINIT
 
C Read paths from command file
 
        IF (GETARG(1,TKNPTH,81).EQ.-100) CALL NAMES(1,TKNPTH)
        IF (GETARG(2,CMTPTH,81).EQ.-100) CALL NAMES(2,CMTPTH)
        IF (GETARG(3,POLPTH,81).EQ.-100) CALL NAMES(3,POLPTH)
        IF (GETARG(4,OPTPTH,81).EQ.-100) CALL NAMES(4,OPTPTH)
 
C Open required files
 
        IODTKN=OPEN(TKNPTH,0)
        IF (IODTKN.EQ.-1) CALL ERROR('Can''t Open token path')
        IODCMT=OPEN(CMTPTH,0)
        IF (IODCMT.EQ.-1) CALL ERROR('Can''t Open comment path')
        IODPOL=CREATE(POLPTH,1)
        IF (IODPOL.EQ.-1) CALL ERROR('Can''t Open output file')
        IODOPT=OPEN(OPTPTH,0)
        IF (IODOPT.EQ.-1 .AND. OPTPTH(1).NE.129 .AND.
     +      EQUAL(OPTPTH,NOOPTS).NE.-2)
     +      CALL ERROR('Can''t Open option file')
 
C Default parameters are set up in block data POLBLK
 
C Setup user-specified option values
 
        CALL PLOPTF(IODOPT)
        DO 100 I=5,10
 100        IF (GETARG(I,OPT,134).NE.-100) CALL POLOPT(OPT,.FALSE.)
 
C Initialise internal variables
 
        CALL INIPOL(ZTKGTI(1,IODTKN,IODCMT),IODPOL)
 
C Now process the input, one statement at a time
 
 200    CALL POLISH(NOTDON)
        IF (NOTDON) GOTO 200
 
C Finish up
 
        NERROR=ZPLERR()
        IF (NERROR.EQ.0) THEN
            CALL ZMESS('[ISTPL Normal Termination]',1)
            CALL ZQUIT(-2)
        ELSE
            CALL ZCHOUT('[ISTPL Termination, ',1)
            CALL PUTDEC(NERROR,1)
            CALL ZCHOUT(' Error',1)
            IF (NERROR.GT.1) CALL PUTC(115)
            CALL ZMESS(' Found]',1)
            CALL ZQUIT(-1002)
        END IF
 
        END
C ----------------------------------------------------------------------
C
C       N A M E S  -  Input a pathname after prompting
C
 
        SUBROUTINE NAMES(NUMB,PATH)
        INTEGER NUMB,PATH(*)
 
        INTEGER JUNK,PROMPT(22,4)
 
        INTEGER ZGTCMD
        EXTERNAL ZGTCMD,ZPRMPT
 
        DATA (PROMPT(I,1),I=1,21)/73,110,112,117,116,32,
     +        116,111,107,101,110,32,115,116,114,101,
     +        97,109,58,32,129/,
     +       (PROMPT(I,2),I=1,21)/73,110,112,117,116,32,
     +        99,111,109,109,101,110,116,32,102,105,
     +        108,101,58,32,129/,
     +       (PROMPT(I,3),I=1,18)/80,111,108,105,115,104,
     +        101,100,32,111,117,116,112,117,116,58,
     +        32,129/,
     +       (PROMPT(I,4),I=1,14)/79,112,116,105,111,110,
     +        32,102,105,108,101,58,32,129/
 
        CALL ZPRMPT(PROMPT(1,NUMB))
        JUNK=ZGTCMD(PATH,0)
 
        END
